<%@page import="com.gkwave.module.dao.SpecialOfferDAO"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="java.util.List"%>
<%@page import="com.gkwave.module.bean.CityBean"%>
<%@page import="com.gkwave.module.dao.CityDAO"%>
<%@page import="java.util.Iterator"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>::Special Offer::</title>
<script type="text/javascript">
	function submitPage(arg){
		document.forms["specialoffer"].hidden_1.value=arg;
		document.forms["yospecialofferga"].submit();
	}
</script>
</head>
<%
CityDAO dao = new CityDAO();
CityBean list = dao.getAllCity();
String idCity = (String)request.getParameter("idCity");
String txtDescroption1 = (String)request.getParameter("txtDescroption1");
String txtDescroption2 = (String)request.getParameter("txtDescroption2");
String txtDescroption3 = (String)request.getParameter("txtDescroption3");
String txtDescroption4 = (String)request.getParameter("txtDescroption4");
String txtDescroption5 = (String)request.getParameter("txtDescroption5");
boolean result = false;
boolean isSubmitted = false;
String hidden_1 = (String)request.getParameter("hidden_1");
if(hidden_1!= null && hidden_1.equals("save")){
	SpecialOfferDAO dao1 = new SpecialOfferDAO();
	result = dao1.saveSpecialOffers(Integer.parseInt(idCity), txtDescroption1, txtDescroption2, txtDescroption3, txtDescroption4, txtDescroption5);
	if(result){
		isSubmitted = true;
	}
}
%>
<body>
<form name="specialoffer" action="specialoffer" method="post">
<input type="hidden" name="hidden_1">
	<table>
		<thead>Special Offer</thead>
			<%
			if(isSubmitted){
				if(result){
			%>
				<tr align="center">
					<td align="center" colspan="2">Data saved successfully!!!</td>
				</tr>
			<%
				}else{
			%>
				<tr align="center">
					<td align="center" colspan="2">Error...!!!</td>
				</tr>
			<%
				}
			}
			%>
		<tr>		
		<tr>	
			<td>City</td>
			<td>
				<select name="idCity">
					<option value="0">--Select--</option>
				<%
					if(list!=null){
						Iterator ite = list.entries.iterator();
						while(ite.hasNext()){
						CityBean bean = (CityBean)ite.next();
						Integer id = bean.getIdCity();
						String name = bean.getNmCity();
				%>
					<option value='<%=id%>'><%=name %></option>
				<%
						}
					}
				%>
				</select>
			</td>			
		</tr>
		<tr>	
			<td>Description 1</td><td><textarea rows="4" name="txtDescroption1" cols="35"></textarea></td>
		</tr>
		<tr>	
			<td>Description 2</td><td><textarea rows="4" name="txtDescroption2" cols="35"></textarea></td>
		</tr>
		<tr>	
			<td>Description 3</td><td><textarea rows="4" name="txtDescroption3" cols="35"></textarea></td>
		</tr>
		<tr>	
			<td>Description 4</td><td><textarea rows="4" name="txtDescroption4" cols="35"></textarea></td>
		</tr>
		<tr>	
			<td>Description 5</td><td><textarea rows="4" name="txtDescroption5" cols="35"></textarea></td>
		</tr>										
		<tr>
			<td><input type="submit" onclick="submitPage('save')" value="Save"></td><td><input type="reset" value="Reset"></td>
		</tr>
	</table>
</form>
</body>
</html>